package com.tvein.sanguo.action.controller.tool
{
	//flash
	//pureMVC
	import org.puremvc.as3.multicore.interfaces.ICommand;
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.utilities.fabrication.patterns.command.SimpleFabricationCommand;
	//custom
	import com.tvein.sanguo.action.common.GameConstants;
//
	public class ToolCommand extends SimpleFabricationCommand implements ICommand
	{
		override public function execute(notification:INotification) : void
		{
			switch(notification.getBody()[0])
			{
				case "-showBox":
					sendNotification(GameConstants.ACTION_TOOL, notification.getBody()[1]);
					break;
				case "-close":
					sendNotification(GameConstants.ACTION_CLOSE, notification.getBody()[1]);
					break;
				case "-setVolume":
					switch(notification.getBody()[1].split(":")[0])
					{
						case "Music":
							routeNotification(GameConstants.MODULE_INVOKE, ["-init", ["musicVol", int(notification.getBody()[1].split(":")[1])]], null, "*");
							sendNotification(GameConstants.ACTION_INIT, ["musicVol", int(notification.getBody()[1].split(":")[1])]);
							break;
						case "Effect":
							routeNotification(GameConstants.MODULE_INVOKE, ["-init", ["effectVol", int(notification.getBody()[1].split(":")[1])]], null, "*");
							sendNotification(GameConstants.ACTION_INIT, ["effectVol", int(notification.getBody()[1].split(":")[1])]);
							break;
						case "Voice":
							routeNotification(GameConstants.MODULE_INVOKE, ["-init", ["voiceVol", int(notification.getBody()[1].split(":")[1])]], null, "*");
							sendNotification(GameConstants.ACTION_INIT, ["voiceVol", int(notification.getBody()[1].split(":")[1])]);
							break;
					}
					break;
				case "-saveVolume":
					routeNotification(GameConstants.GAME_CONSOLE, ["-gameCommand", "RoleCall(0, RoleConfig, Sound," + notification.getBody()[1] + ");"], null, "*");
					sendNotification(GameConstants.ACTION_CLOSE, "ToolSound");
					break;
				case "-gameCommand":
					routeNotification(GameConstants.GAME_CONSOLE, ["-gameCommand", notification.getBody()[1]], null, "*");
					sendNotification(GameConstants.ACTION_CLOSE, "*");
					break;
				case "-exit":
					routeNotification(GameConstants.GAME_CONSOLE, ["-gameCommand", "GameExit();"], null, "*");
					break;
				case "-readMail":
					routeNotification(GameConstants.GAME_CONSOLE, ["-gameCommand", "MailHandle(1, " + notification.getBody()[1] + ");"], null, "*");
					break;
				case "-sendMail":
					routeNotification(GameConstants.GAME_CONSOLE, ["-gameCommand", "MailHandle(2, " + escape(notification.getBody()[1][0]) + ", " + escape(notification.getBody()[1][1]) + ", " + escape(notification.getBody()[1][2]) + ");"], null, "*");
					break;
				case "-deleteMail":
					routeNotification(GameConstants.GAME_CONSOLE, ["-gameCommand", "MailHandle(3, " + notification.getBody()[1] + ");"], null, "*");
					break;
			}
		}
	}
}